package com.elective.courseselect.controller;

import com.elective.courseselect.entity.StudentCourseEntity;
import com.elective.courseselect.service.StudentCourseService;
import com.elective.courseselect.utils.PageUtils;
import com.elective.courseselect.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;
 /**
 * 
 *
 * @author lee
 * @email 943204006@qq.ccom
 * @date 2021-09-04 19:22:34
 */
@RestController
@RequestMapping("courseselect/studentcourse")
public class StudentCourseController {
    @Autowired
    private StudentCourseService studentCourseService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = studentCourseService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		StudentCourseEntity studentCourse = studentCourseService.getById(id);

        return R.ok().put("studentCourse", studentCourse);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody StudentCourseEntity studentCourse){
		studentCourseService.save(studentCourse);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody StudentCourseEntity studentCourse){
		studentCourseService.updateById(studentCourse);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		studentCourseService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
